package com.dding.cms.base.web.widget.handler;

import static com.dding.cms.base.web.ActionConstants.WIDGET_TYPE_TEXT;

import java.util.Map.Entry;

import com.dding.cms.base.web.widget.IWidgetContext;
import com.dding.cms.base.web.widget.Widget;

@Widget(Id = WIDGET_TYPE_TEXT)
public class DefaultTextHandler extends AbstractWidgetHandler {

	@Override
	public Object handleSet(IWidgetContext widgetContext) {

		String[] result = new String[2];
		for (Entry<String, Object> entry : widgetContext.getParameters()
				.entrySet()) {
			result[0] = entry.getKey();
			result[1] = ((String[]) entry.getValue())[0];
		}
		return result;
	}

	@Override
	public Object handleUpdateField(IWidgetContext widgetContext) {

		Object object = null;
		for (Entry<String, Object> entry : widgetContext.getParameters()
				.entrySet()) {
			object = entry.getValue();
		}
		return object;
	}
}
